/*Copyright 2020 Huawei Technologies Co., Ltd
 *Licensed under the Apache License, Version 2.0 (the "License");
 *you may not use this file except in compliance with the License.
 *You may obtain a copy of the License at
 *
 *http://www.apache.org/licenses/LICENSE-2.0
 *
 *Unless required by applicable law or agreed to in writing, software
 *distributed under the License is distributed on an "AS IS" BASIS,
 *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *See the License for the specific language governing permissions and
 *limitations under the License.
 *
 * */

package com.huaweicloud.sdk.iot.device.timesync;

import android.os.Parcel;
import android.os.Parcelable;

import com.google.gson.annotations.SerializedName;

public class TimeSyncMessage implements Parcelable {
    /**
     * 设备发送时间戳
     */
    @SerializedName("device_send_time")
    private long deviceSendTime;

    /**
     * 平台收到的同步时间请求时的时间戳
     */
    @SerializedName("server_recv_time")
    private long serverRecvTime;

    public long getDeviceSendTime() {
        return deviceSendTime;
    }

    public void setDeviceSendTime(long deviceSendTime) {
        this.deviceSendTime = deviceSendTime;
    }

    public long getServerRecvTime() {
        return serverRecvTime;
    }

    public void setServerRecvTime(long serverRecvTime) {
        this.serverRecvTime = serverRecvTime;
    }

    public long getServerSendTime() {
        return serverSendTime;
    }

    public void setServerSendTime(long serverSendTime) {
        this.serverSendTime = serverSendTime;
    }

    /**
     * 平台发送同步时间响应时的时间戳
     */
    @SerializedName("server_send_time")
    private long serverSendTime;

    public TimeSyncMessage() {
    }

    protected TimeSyncMessage(Parcel in) {
        deviceSendTime = in.readLong();
        serverRecvTime = in.readLong();
        serverSendTime = in.readLong();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeLong(deviceSendTime);
        dest.writeLong(serverRecvTime);
        dest.writeLong(serverSendTime);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<TimeSyncMessage> CREATOR = new Creator<TimeSyncMessage>() {
        @Override
        public TimeSyncMessage createFromParcel(Parcel in) {
            return new TimeSyncMessage(in);
        }

        @Override
        public TimeSyncMessage[] newArray(int size) {
            return new TimeSyncMessage[size];
        }
    };

    @Override
    public String toString() {
        return "TimeSyncMessage{"
                + "deviceSendTime=" + deviceSendTime
                + ", serverRecvTime=" + serverRecvTime
                + ", serverSendTime=" + serverSendTime
                + '}';
    }
}
